//
//  PLDirectory.h
//  Plankton
//
//  Created by Marc Schlichte on 2008-07-13.
//  Copyright 2008 Framework Labs. All rights reserved.
//

#import <Cocoa/Cocoa.h>

@class PLPlatform, PLPattern;

@protocol PLDirectoryDelegate;

@interface PLDirectory : NSObject 
{
	PLPlatform				*platform;
	NSString				*dirAid;
	id<PLDirectoryDelegate>	delegate;
	NSMutableDictionary		*serviceToAidsDict;
	NSMutableSet			*peers;
	PLPattern				*queryPattern;
	
	BOOL					isSearching;
	NSMutableSet			*searchResult;
	NSMutableSet			*outstandingPeers;
	NSString				*serviceToSearch;
}

- (id)initWithPlatform:(PLPlatform *)platform;

@property(assign) id<PLDirectoryDelegate> delegate;

@property(readonly) NSString *aid;

- (void)registerAid:(NSString *)aid forService:(NSString *)service;
- (void)unregisterAid:(NSString *)aid;

- (BOOL)searchAidsForService:(NSString *)service;

- (void)addPeer:(NSString *)aid;
- (void)removePeer:(NSString *)aid;

@end

@protocol PLDirectoryDelegate <NSObject>

- (void)directory:(PLDirectory *)directory foundAid:(NSString *)aid forService:(NSString *)service;
- (void)directory:(PLDirectory *)directory searchDoneForService:(NSString *)service;

@end
